// https://vitepress.dev/guide/custom-theme
// @ts-ignore
import { h } from 'vue'
import type { Theme } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
// 自定义主题样式
import './style.css'

// 导入Element Plus组件库
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

/**
 * 首页炫彩效果
 */
// @ts-ignore
import Confetti from "./components/Confetti.vue";

/**
 * Element Plus  文档扩展
 */
// @ts-ignore
import ElTips from '../components/el-tips.vue'
// @ts-ignore
import ElImg from '../components/el-img.vue'
// @ts-ignore
import ElOpen from '../components/el-open.vue'
// @ts-ignore
import ElVideo from '../components/el-video.vue'
// @ts-ignore
import ElCover from '../components/el-cover.vue'
// @ts-ignore
import ElH2 from '../components/el-h2.vue'
// @ts-ignore
import ElH3 from '../components/el-h3.vue'
// @ts-ignore
import ElFont from '../components/el-font.vue'
// @ts-ignore
import ElVision from '../components/el-vision.vue'

/**
 * DOC文档前插槽
 */
import docBefore from './components/docBefore.vue'

export default {
  extends: DefaultTheme,
  Layout: () => {
    return h(DefaultTheme.Layout, null, {
      // https://vitepress.dev/guide/extending-default-theme#layout-slots
      // 'sidebar-nav-before': () => h(docBefore)
    })
  },
  enhanceApp({ app, router, siteData }) {
    // ...
    // 注册彩带特效
    app.component("Confetti", Confetti); 
    
    // 注册Element Plus图标库
    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
      app.component(key, component)
    }

    /**
     * 注册Element Plus文档扩展
     */
    app.component('el-tips', ElTips)
    app.component('el-img', ElImg)
    app.component('el-open', ElOpen)
    app.component('el-video', ElVideo)
    app.component('el-cover', ElCover)
    app.component('el-vision', ElVision)
    app.component('el-h2', ElH2)
    app.component('el-h3', ElH3)
    app.component('el-font', ElFont)

    // 使用Element Plus组件库
    app.use(ElementPlus)
  }
} satisfies Theme
